package com.crm.customers.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.crm.base.dao.BaseDao;
import com.crm.customers.dao.CustomerCategoryDao;
import com.crm.customers.model.CustomerCategory;

@Repository("customerCategoryDao")
public class CustomerCategoryDaoImpl extends BaseDao implements CustomerCategoryDao {
	
	private static final String MAPPER_NAMESPACE = "CustomerCategoryMapper.";

	@Override
	public CustomerCategory insertCustomerCategory(CustomerCategory cc) {
		insert(MAPPER_NAMESPACE+"insertCustomerCategory", cc);
		return cc;
	}

	@Override
	public List<CustomerCategory> getCustomerCategoryListById(Long cusid) {
		return selectList(MAPPER_NAMESPACE+"getCustomerCategoryListById", cusid);
	}

	@Override
	public CustomerCategory getCustomerCategoryListByCategoryId(Long id) {
		return selectOne(MAPPER_NAMESPACE+"getCustomerCategoryListByCategoryId", id);
	}

	@Override
	public CustomerCategory updateCustomerCategory(CustomerCategory cc) {
		update(MAPPER_NAMESPACE+"updateCustomerCategory", cc);
		return cc;
	}

	@Override
	public List<CustomerCategory> getcustcatlistByid(Long id) {
		return selectList(MAPPER_NAMESPACE+"getcustcatlistByid", id);
	}

	@Override
	public List<CustomerCategory> getCustomerCategoryListByParams(
			CustomerCategory cc) {
		List<CustomerCategory> list = selectList(MAPPER_NAMESPACE+"getCustomerCategoryListByParams", cc);
		if (list != null && list.size() > 0) {
			list.get(0).setTotalResults((Integer)selectOne(MAPPER_NAMESPACE+"getCustomerCategoryListCountByParams", cc));
		}
		return list;
	}

}
